package org.example.platform.design.simplefactory.version2;


import java.util.Arrays;

/**
 * 校验非空
 */
public class Futil {

    static final String[] fhs = new String[]{"+","-","*","/"};

    public static void isNumNotNull(Integer num) throws Exception {
        if(null == num){
            throw new Exception("输入的第一位数字不能为空！");
        }
    }

    public static void isNum2NotNull(Integer num2) throws Exception {
        if(null == num2){
            throw new Exception("输入的第二位数字不能为空！");
        }
    }

    public static void isFhNotNull(String fh) throws Exception {
        if(null == fh || "".equals(fh)){
            throw new Exception("输入的符号不能为空！");
        }else if(!Arrays.asList(fhs).contains(fh)){
            throw new Exception("输入的符号不正确！正确符号为+-*/");
        }
    }

    public static void isNumNotZero(Integer num) throws Exception {
        if (num == 0) {
            throw new Exception("除数不能为0！");
        }
    }
}
